package com.bdc.activity;

import com.bdc.R;
import com.bdc.Var;
import com.bdc.util.ServiceUtils;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class RecordActivity extends Activity {
	
	private TextView memoryView;
	private TextView descriptionView;
	private TextView tagView;
	private Button button;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.record);
		
		memoryView = (TextView) findViewById(R.record.memory);
		descriptionView = (TextView) findViewById(R.record.description);
		tagView = (TextView) findViewById(R.record.tag);
		
		//button = (Button) findViewById(R.record.saveButton);
		//button.setOnClickListener(clickListener);
	}
	
	private OnClickListener clickListener = new OnClickListener(){

		public void onClick(View v) {
			String memory = RecordActivity.this.memoryView.getText().toString();
			String description = RecordActivity.this.descriptionView.getText().toString();
			String tag = RecordActivity.this.tagView.getText().toString();
			
			String methodUrl = Var.service.addRecord + "/" + memory + "/" + description + "/" + tag;
			String result = ServiceUtils.invokeService(methodUrl);
			
			boolean isSuccess = ServiceUtils.isSuccess(result);
			if(isSuccess) {
				RecordActivity.this.memoryView.setText("");
				RecordActivity.this.descriptionView.setText("");
				RecordActivity.this.tagView.setText("");
			}
		}
	};
}
